﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace VoiceMessager.Views
{
    /// <summary>
    /// Interaction logic for FrameListItemView.xaml
    /// </summary>
    public partial class FrameListItemView : UserControl
    {
        public FrameListItemView()
        {
            InitializeComponent();
            ControlExpandStoryboard = new Storyboard();
            Animation = new DoubleAnimation
            {
                From = 50,
                To = 250,
                Duration = new Duration(TimeSpan.FromMilliseconds(400)),
                EasingFunction = new BackEase
                {
                    Amplitude = 0.5,
                    EasingMode = EasingMode.EaseOut
                }
            };
            ControlExpandStoryboard.Children.Add(Animation);
            Storyboard.SetTargetName(Animation, nameof(FrameListItemViewControl));
            Storyboard.SetTargetProperty(Animation, new PropertyPath(HeightProperty));
        }

        public Storyboard ControlExpandStoryboard;
        public DoubleAnimation Animation;

        private void Expand_Click(object sender, RoutedEventArgs e)
        {
            Animation.From = FrameListItemViewControl.Height > 60 ? 250 : 50;
            Animation.To = FrameListItemViewControl.Height > 60 ? 50 : 250;
            ControlExpandStoryboard.Begin(this, true);
        }

        private void FrameListItemViewControl_Loaded(object sender, RoutedEventArgs e)
        {
            Animation.From = 20;
            Animation.To = 50;
            ControlExpandStoryboard.Begin(this, true);
        }
    }
}
